<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Server-Sent 事件指的是网页自动从服务器获得更新</title>
</head>
<body>
<h1>获得服务器更新</h1>
<div id="result"></div>

<script>
  if(typeof(EventSource)!=="undefined")
  {
    var source=new EventSource("../../audio/demo_sse.php");
    source.onmessage=function(event)
    {
      document.getElementById("result").innerHTML+=event.data + "<br />";
    };
  }
  else
  {
    document.getElementById("result").innerHTML="抱歉，您的浏览器不支持 server-sent 事件 ...";
  }
</script>
</body>
</html>